<template>
  <div class="goodslistContainer">
    <!-- 头部 -->
    <div class="header">
      <div class="center">
        <van-icon name="wap-home-o" class="icc" size="28" @click="toHome" />
        <div class="logo icon-logo"></div>
        <van-icon name="search" class="icci" size="28" @click="toSearch" />
        <van-icon name="cart-o" class="icco" size="28" @click="toCart" />
      </div>
    </div>

    <!-- 标签栏 -->
    <div class="tab">
      <van-tabs class="tabList">
        <van-tab class="tabItem" :title="category.name">
          <div class="external">
            <!-- 数据列表 -->
            <div class="centerList">
              <div
                class="centerItem"
                v-for="(gory, index) in itemList"
                :key="gory.id"
              >
                <img class="Img" :src="gory.listPicUrl" alt="" />
                <div class="center">
                  <img
                    class="logo"
                    src="https://yanxuan.nosdn.127.net/static-union/1640835741e1f775.png"
                    alt=""
                  />
                  {{ gory.name }}
                </div>
                <div class="price">
                  <div class="left">到手价￥</div>
                  <div class="out">
                    {{ gory.finalPriceInfoVO.priceInfo.finalPrice.price }}
                  </div>
                  <div class="right">￥{{ gory.retailPrice }}</div>
                </div>
                <div class="banner-warp">
                  <div class="right">
                    {{ gory.finalPriceInfoVO.banner.content }}
                  </div>
                </div>
              </div>
            </div>
            <div class="aaa"></div>
          </div>
        </van-tab>
      </van-tabs>
    </div>

    <div class="line"></div>

    <!-- 内容区 -->
  </div>
</template>

<script>
import { mapGetters, mapState } from "vuex";
export default {
  name: "GoodsList",
  data() {
    return {
      subCategoryId: "",
      categoryId: "",
    };
  },
  computed: {
    ...mapState({
      goryList: (state) => state.Category.goryList,
      itemList: (state) => state.Category.itemList,
    }),
    ...mapGetters(["category"]),

    // pri() {
    //   return goryList.itemList.gory.finalPriceInfoVO.banner.content;
    // },
  },
  mounted() {
    this.getId(this.$route.query.subId, this.$route.query.Id);
  },
  methods: {
    getId(subid, id) {
      this.subCategoryId = subid;
      this.categoryId = id;
      console.log("1", this.subCategoryId, this.categoryId);
      let { subCategoryId, categoryId } = this;
      this.$store.dispatch("getgoodsList", { subCategoryId, categoryId });
    },
    // 去主页
    toHome() {
      this.$router.push("/home");
    },
    // 去搜索页
    toSearch() {
      this.$router.push({
        path: "/search",
        query: {
          redirect: "/goods-list",
        },
      });
    },
    // 去购物车
    toCart() {
      this.$router.push("/cart");
    },
  },
};
</script>

<style lang="less" scoped>
.aaa {
  height: 50px;
  background-color: #ffffff;
}
.goodslistContainer {
  height: 100%;
  .header {
    background-color: #fafafa;
    border-bottom: 1px solid #dedede;
    display: flex;
    justify-content: center;
    height: 44px;
    // background-color: red;
    .center {
      width: 355px;
      height: 44px;
      // background-color: skyblue;
      display: flex;
      align-items: center;
      .icc {
        color: #696969;
      }
      .logo {
        // margin-top: 3px;
        width: 90px;
        height: 28px;
        margin-left: 100px;
      }
      .icon-logo {
        background-image: url(//yanxuan-static.nosdn.127.net/hxm/tetris/common-mobile/sprite/hd.png);
        background-size: 130px;
      }
      .icci {
        margin-left: 60px;
        color: #696969;
      }
      .icco {
        margin-left: 10px;
        color: #696969;
      }
    }
  }
  .tab {
    height: 30px;
    /deep/ .van-tabs__wrap {
      height: 30px;
    }

    .tabList {
      // @tabs-card-height: 30px;
      // line-height：1px
      .tabItem {
        height: 30px;
        @tabs-card-height: 30px;
        .external {
          width: 100%;
          .centerList {
            // background-color: red;
            margin-top: 55px;
            display: flex;
            flex-wrap: wrap;
            .centerItem {
              width: 187px;
              height: 309px;
              // background-color: skyblue;
              .Img {
                height: 172px;
                width: 172px;
                // text-align: center;
                margin-left: 10px;
                border-radius: 10px;
              }
              .center {
                width: 172px;
                height: 45px;
                // background-color: green;
                margin-left: 10px;
                display: flex;
                font-size: 15px;
                display: -webkit-box;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 2;
                word-break: break-all;
                .logo {
                  width: 44px;
                  height: 17px;
                }
                .text {
                  font-size: 15px;
                }
              }
              .price {
                margin-top: 5px;
                width: 30px;
                width: 172px;
                display: flex;
                align-items: center;
                .left {
                  font-weight: 700;
                  color: #fa1e32;
                  font-size: 12px;
                  margin-left: 10px;
                }
                .out {
                  margin-top: -5px;
                  color: #fa1e32;
                  font-size: 20px;
                  font-weight: 1000;
                }
                .right {
                  font-size: 12px;
                  color: #999999;
                  text-decoration: line-through;
                }
              }
              .banner-warp {
                width: 172px;
                height: 23px;
                margin-left: 10px;

                .right {
                  width: 80px;
                  background-color: red;
                  font-weight: 1000;
                  font-size: 12px;
                  color: white;
                  padding: 2px 6px;
                  border-radius: 10px;
                }
              }
            }
          }
        }
      }
    }
  }
  .line {
    height: 10px;
    width: 100%;
    background-color: #eeeeee;
  }
}
</style>
